package com.example.demo.Repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.example.demo.Entity.Experience;

import java.util.List;

/**
 * @version: V0.3
 * @author: 郑皓杰 吴嘉鑫
 * @className: IExperienceRepository
 * @packageName: com.example.demo.Repository
 * @description: 这是经历实体数据链接的接口
 * @data: 2021-07-14
 **/

public interface IExperienceRepository extends JpaRepository<Experience,Integer>{

	
	public List<Experience> findByEmpid(Integer empid);
	public Experience findByDescriptionid(Integer descriptionid);
	public List<Experience> findByCompanyID(Integer companyID);

	@Query(value = "select empid from experience b  where b.companyid=?1", nativeQuery = true)
    public List<Integer> findempidBycompanyID(Integer companyID);
	
	@Query(value = "select descriptionid from experience b  where b.empid=?1",nativeQuery = true)
	public List<Integer> finddesidByempid(Integer empid);
	
	
	//@Query(value = "select * from experience b  where b.empid=?1&b.",nativeQuery = true)
	public Experience findByEmpidAndCompanyID(Integer empid, Integer companyID);
	//value = "select s from User as s where s.username like concat('%',?1,'%')
	@Query(value = "select * from experience as b where b.position like concat('%',?1,'%')",nativeQuery=true)
	public List<Experience> findByJobKeyword(String keyword);
	
	@Query(value="select expid from experience b where b.empid=?1 and b.suspended is null",nativeQuery=true)
	public Integer findExpidByEmpidAndStillOnWork(Integer empid);
	
	@Query(value="select * from experience as b where b.empid=?1 and b.suspended is null",nativeQuery=true)
	public Experience findByEmpidAndStillOnWork(Integer empid);
	
	@Query(value="select empid from experience b where b.companyid=?1 and b.suspended is null",nativeQuery=true)
	public List<Integer> findEmpidBycompanyIDAndStillOnWork(Integer companyID);
	
	@Query(value = "select salary from experience b  where b.empid=?1",nativeQuery = true)
	public List<Integer> findsalaryByempid(Integer empid);
}

 //and b.suspended=?2

